#include <iostream>
#include <algorithm>
#include <string>
#include <cctype>
#include <cmath>
using namespace std;
const int N = 110;
int a[N]; 

int main()
{
    int n,b;
	cin >> n >> b;
	for(int i = 0;i<n;i++)
	{
		cin >> a[i];
	 } 
	 sort(a,a+n);
	 for(int i = 0;i<n;i++)
	 {
	 	if(a[i]%b == 0)
	 	continue;
	 	if(a[i] >='A' && a[i] <='Z')
	 	cout << char(a[i]) << " ";
	 	else
	 	cout << a[i] << " ";
	 }
   
	return 0;
}
